<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8"/>
        <title>函数特点</title>
    </head>
    <body>
        <script type="text/javascript">
        //函数声明提升

       /*  var fn = function () {
           console.log("123");
       };

        console.log(fn());


        function fn() {
           console.log("456");
       };
 */


       //函数作用域
/*        function abc(a,b){
           var height = a;
           var weight = b;
           var result = weight / (height ^ 2);
           var fn = function(manType){
               console.log("身高："+height);
               console.log("体重：" + weight);
               switch(manType){
                   case "亚洲人":
                       
                       if(result>25){
                           console.log("偏胖");
                       }else{
                           console.log("偏瘦");
                       }
                       break;
                   case "非洲人":
                      
                       if (result > 40) {
                           console.log("偏胖");
                       } else {
                           console.log("偏瘦");
                       }
                       break;
                   case "欧洲人":
                      
                       if (result > 35) {
                           console.log("偏胖");
                       } else {
                           console.log("偏瘦");
                       } 
                       break;
                    
               };
               
           }
        return fn;
        } */
       
        //全局作用域
        var a = 1;
        var b = 2;

        function abc(){
            c = "彭于晏";
            console.log(a);
        }

        abc();
        console.log(c);

        (function(){
           var a=4;
            console.log(a);
        })();
        console.log(a);
        </script>
    </body>
</html>